package Model;

import static com.sun.corba.se.spi.presentation.rmi.StubAdapter.request;
import java.io.Serializable;

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
/**
 *
 * @author thien_000
 */
import java.sql.*;

public class bean_login implements Serializable {

    public boolean checkLogin(String username, String password) {
        Connection con = null;
        ResultSet rs = null;
        try {
            con = Connect.GetConnect();
            String sql = "SELECT * FROM nhanvien WHERE TaiKhoan=? and MatKhau=? and ChucVu=?";
            PreparedStatement stm = con.prepareStatement(sql);
            stm.setString(1, username);
            stm.setString(2, password);
            stm.setString(3, "admin");
            rs = stm.executeQuery();
            boolean result = rs.next();
            stm.close();
            rs.close();
            con.close();
            if (result) {
                return true;
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return false;
    }
}
